#ifndef __MYDICT_H__
#define __MYDICT_H__

#include <string>
#include <vector>
#include <unordered_map>
#include <set>

using namespace std;

class Mydict
{
public:
    static Mydict* createInstance();
    static void destroy();
    void init(const char* dictEnPath,const char* dictCnPath);
    vector<pair<string,int>>& getDict();
    unordered_map<string,set<int>>& getIndexTable();
    void store_index(const char* filepath);
private:
    Mydict() {}
    ~Mydict() {}
    void read(const char* filepath);
    void build_index();
    void deal_cn(const string& word,int cnt);
    void deal_en(const string& word,int cnt);
    int getUtf8CharLength(char c);

private:
    static Mydict* _pInstance;
    vector<pair<string,int>> _dict;
    unordered_map<string,set<int>> _index_table;
};

#endif
